import axios from "axios";
import { showLoadingToast, closeToast } from "vant";

//axios拦截器
// Add a request interceptor
axios.interceptors.request.use(
  function (config) {
    showLoadingToast({
      message: "加载中...",
      forbidClick: true,
    });
    return config;
  },
  function (error) {
    return Promise.reject(error);
  }
);

// Add a response interceptor
axios.interceptors.response.use(
  function (response) {
    closeToast();
    return response;
  },
  function (error) {
    closeToast();
    return Promise.reject(error);
  }
);
